Skip to content

Fix SDO truncation of unknown datatypes #447

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

sveinse
Copy link
Collaborator

@sveinse sveinse commented May 27, 2024

This is a proposed fix for #436

@sveinse sveinse marked this pull request as draft May 27, 2024 18:29
@sveinse sveinse changed the title Proposed fix for #440 Proposed fix for #436 May 27, 2024
@sveinse
Copy link
Collaborator Author

sveinse commented May 27, 2024

(It fails checks because it depends on pretty_index() from #443, which is a minor detail in this discussion.)

@sveinse sveinse changed the title Proposed fix for #436 Fix SDO truncation of unknown datatypes Jun 14, 2025
@sveinse sveinse force-pushed the feature-proposed-data-type-fix branch from af98492 to 49e4a73 Compare June 15, 2025 00:11
Copy link

codecov bot commented Jun 15, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

📢 Thoughts on this report? Let us know!

@sveinse sveinse marked this pull request as ready for review June 15, 2025 00:52
Copy link
Member

@acolomb acolomb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've replied to the discussion in #436 concerning the approach taken here. Will come up with a less intrusive suggestion shortly.

Comment on lines +433 to +435
logger.warning(f"Decoding data {data!r} of type 0x%X at %s",
self.data_type, pretty_index(self.index, self.subindex))
logger.warning(f"Size: {size} bytes, data length: {len(data)} bytes")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is definitely too much logging, both by number of messages and at a too high severity level.

And please try to stick to the previously discussed rule: logging methods use % formats and parameters, and f-strings for everything else.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I agree. These are left-overs from my own debugging. My bad. I'll remove them.

pretty_index(self.index, self.subindex), self.data_type,
size, len(data))
# Truncate the data to the expected size
data = data[:size]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's way easier switching to the .unpack_from() method which simply discards trailing extra data. I don't think this severe warning is generally desired.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm going to remove the warning altogether.

@sveinse
Copy link
Collaborator Author

sveinse commented Jun 15, 2025

Superseded by #591. Closing

@sveinse sveinse closed this Jun 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants